﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace Max.PH6_2006A.LowCode.EFDbFirstCodeCreate.Models
{
    public partial class PH6_2006A_LowCodeContext : DbContext
    {
        public PH6_2006A_LowCodeContext()
        {
        }

        public PH6_2006A_LowCodeContext(DbContextOptions<PH6_2006A_LowCodeContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Employee> Employees { get; set; } = null!;
        public virtual DbSet<SystemMenu> SystemMenus { get; set; } = null!;
        public virtual DbSet<SystemOrganizational> SystemOrganizationals { get; set; } = null!;
        public virtual DbSet<SystemRole> SystemRoles { get; set; } = null!;
        public virtual DbSet<SystemRoleMenu> SystemRoleMenus { get; set; } = null!;
        public virtual DbSet<SystemUser> SystemUsers { get; set; } = null!;
        public virtual DbSet<SystemUserRole> SystemUserRoles { get; set; } = null!;

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("server=.;database=PH6_2006A_LowCode;uid=sa;pwd=qwe123;");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Employee>(entity =>
            {
                entity.ToTable("Employee");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasDefaultValueSql("(newid())")
                    .HasComment("主键");

                entity.Property(e => e.Age).HasComment("年龄");

                entity.Property(e => e.Birthday)
                    .HasColumnType("datetime")
                    .HasComment("出生年月");

                entity.Property(e => e.CreatedBy)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("创建人");

                entity.Property(e => e.CreatedTime)
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("(getdate())")
                    .HasComment("创建时间");

                entity.Property(e => e.EmployeeNo)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("员工工员");

                entity.Property(e => e.Gender)
                    .HasMaxLength(2)
                    .IsUnicode(false)
                    .HasComment("性别（0女，1男，-1未知、其它）");

                entity.Property(e => e.HighestEduction)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("最高学历(在录入的时候，选择，而不是输入）");

                entity.Property(e => e.InDate)
                    .HasColumnType("datetime")
                    .HasComment("入职日期");

                entity.Property(e => e.Name)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("员工姓名");

                entity.Property(e => e.OrganizationalId)
                    .HasColumnName("OrganizationalID")
                    .HasComment("所属部门(组织构架）");

                entity.Property(e => e.OutDate)
                    .HasColumnType("datetime")
                    .HasComment("离职日期");

                entity.Property(e => e.PostId)
                    .HasColumnName("PostID")
                    .HasComment("职务");

                entity.Property(e => e.Statue)
                    .HasMaxLength(10)
                    .IsUnicode(false)
                    .HasDefaultValueSql("('0')")
                    .HasComment("员工状态（在职、离职）");

                entity.Property(e => e.UpdatedBy)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("更新人");

                entity.Property(e => e.UpdatedTime)
                    .HasColumnType("datetime")
                    .HasComment("更新时间");
            });

            modelBuilder.Entity<SystemMenu>(entity =>
            {
                entity.ToTable("SystemMenu");

                entity.HasComment("RBAC之菜单");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasDefaultValueSql("(newid())");

                entity.Property(e => e.CreatedBy)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("创建人");

                entity.Property(e => e.CreatedTime)
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("(getdate())")
                    .HasComment("创建日期");

                entity.Property(e => e.Icon)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("菜单图标");

                entity.Property(e => e.Name)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("菜单名称");

                entity.Property(e => e.Sort)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("排序");

                entity.Property(e => e.Statue)
                    .HasMaxLength(10)
                    .IsUnicode(false)
                    .HasDefaultValueSql("('0')")
                    .HasComment("状态(0正常，1是禁用）");

                entity.Property(e => e.Target)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("打开目标（本页面还是新页面打开该链接）");

                entity.Property(e => e.UpdatedBy)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("更新人");

                entity.Property(e => e.UpdatedTime)
                    .HasColumnType("datetime")
                    .HasComment("更新日期");

                entity.Property(e => e.Url)
                    .HasMaxLength(200)
                    .IsUnicode(false)
                    .HasComment("菜单链接");
            });

            modelBuilder.Entity<SystemOrganizational>(entity =>
            {
                entity.ToTable("SystemOrganizational");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasDefaultValueSql("(newid())")
                    .HasComment("主键");

                entity.Property(e => e.Name)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("名称");

                entity.Property(e => e.ParentId)
                    .HasColumnName("ParentID")
                    .HasComment("父级ID");
            });

            modelBuilder.Entity<SystemRole>(entity =>
            {
                entity.ToTable("SystemRole");

                entity.HasComment("RBAC之角色");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasDefaultValueSql("(newid())");

                entity.Property(e => e.Name)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("角色名称");

                entity.Property(e => e.Remark)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("角色描述");
            });

            modelBuilder.Entity<SystemRoleMenu>(entity =>
            {
                entity.ToTable("SystemRoleMenu");

                entity.HasComment("RBAC之角色和菜单的关联表");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasDefaultValueSql("(newid())");

                entity.Property(e => e.MeunId)
                    .HasColumnName("MeunID")
                    .HasComment("菜单ID");

                entity.Property(e => e.RoleId)
                    .HasColumnName("RoleID")
                    .HasComment("角色ID");
            });

            modelBuilder.Entity<SystemUser>(entity =>
            {
                entity.ToTable("SystemUser");

                entity.HasComment("RBAC之用户");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasDefaultValueSql("(newid())")
                    .HasComment("主健ID");

                entity.Property(e => e.CreatedBy)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("创建人（这个用户是由谁添加的）");

                entity.Property(e => e.CreatedTime)
                    .HasColumnType("datetime")
                    .HasDefaultValueSql("(getdate())")
                    .HasComment("创建时间");

                entity.Property(e => e.LoginName)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("登录名称");

                entity.Property(e => e.NickName)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasComment("昵称");

                entity.Property(e => e.Password)
                    .HasMaxLength(200)
                    .IsUnicode(false)
                    .HasComment("密码（加密）");

                entity.Property(e => e.Statue)
                    .HasMaxLength(1)
                    .IsUnicode(false)
                    .HasDefaultValueSql("('0')")
                    .HasComment("状态(0正常，1禁用）");

                entity.Property(e => e.UpdatedBy)
                    .HasMaxLength(500)
                    .IsUnicode(false)
                    .HasComment("修改人");

                entity.Property(e => e.UpdatedTime)
                    .HasColumnType("datetime")
                    .HasComment("修改时间");
            });

            modelBuilder.Entity<SystemUserRole>(entity =>
            {
                entity.ToTable("SystemUserRole");

                entity.HasComment("RBAC之用户角色关联表");

                entity.Property(e => e.Id)
                    .HasColumnName("ID")
                    .HasDefaultValueSql("(newid())");

                entity.Property(e => e.RoleId)
                    .HasColumnName("RoleID")
                    .HasComment("角色ID");

                entity.Property(e => e.UserId)
                    .HasColumnName("UserID")
                    .HasComment("用户ID");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
